/*
 * ClientReceivingThread.cpp
 *
 *  Created on: Nov 5, 2012
 *      Author: lucas
 */

#include "ClientReceivingThread.h"
#include "../common/CommunicationSocket.h"
#include "Client.h"
#include "Server.h"
#include "../common/SocketErrorException.h"
#include <iostream>

ClientReceivingThread::ClientReceivingThread(CommunicationSocket& csck,
		Server& s, Client& c) : sck(csck), server(s), client(c) {
}

ClientReceivingThread::~ClientReceivingThread() {
}

void ClientReceivingThread::ejecutar() {

	std::string request;
	while (this->running()) {
		try {
			sck.recibir(request);
		}
		catch (SocketErrorException& exc) {
			client.disconnect();
		}
		std::cout << "ClientReceivingThread recibio: " << request << std::endl;
		server.addRequest(request, client);
	}
}




